package com.wbase.demo.work

import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.wbase.base.logger.Logger

class StatisticWorker(context: Context,params:WorkerParameters): Worker(context,params) {
    companion object{
        private const val TAG = "StatisticWorker"
    }

    override fun doWork(): Result {
        try{
            executeStatistics()
            return Result.success()
        }catch (e: Exception){
            return Result.failure()
        }
    }

    private fun executeStatistics() {
        // 真正的执行任务
        Logger.i(TAG,">>>>>>>> start executeStatistics:${Thread.currentThread().name}")
        Thread.sleep(2000L)
        Logger.i(TAG,">>>>>>>> end executeStatistics:${Thread.currentThread().name}")
    }
}